

%macro histcount(type);
     /*count number of payments current/delinquent in past 24 months for all trades*/
     /*constructed from paypat in 02_clean_tradeline99.sas*/
     &type._hist_ontime = paymop1_24;
     &type._hist_3060 = pay3059_24;
     &type._hist_6090 = pay6089_24;
     &type._hist_90120 = pay90119_24;
     &type._hist_120plus = pay120up_24;
%mend;

%macro recentcount(type);
	   &type._debt = acctbal;
	   &type._lim = crdtlim; 
	   &type._num = 1;
	   /*count recent payment status for open trades*/
	   if mop eq 1 then &type._rec_ontime = 1;
	   if mop eq 2 then do; &type._rec_3060 = 1; &type._rec_3060_lot = datecurr; end;
	   if mop eq 3 then do; &type._rec_6090 = 1; &type._rec_6090_lot = datecurr; end;
	   if mop eq 4 then do; &type._rec_90120 = 1; &type._rec_90120_lot = datecurr; end;
	   if mop eq 5 then do; &type._rec_120plus = 1; &type._rec_120plus_lot = datecurr; &type._rec_120plus_f120 = datefirst120; end;
	   if mop eq 9 then do; &type._rec_worse = 1; &type._rec_worse_lot = datecurr; end;
%mend;
